<%@ page contentType="text/html; charset=UTF-8" %>
<%@ page import="java.sql.*"%>
<%@ page import="javax.sql.*"%>
<%@ page import="javax.naming.*"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>DataSource Welcome Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>

<body>
<table cellspacing="0" border=1>
    <thead>
        <tr>
            <th>ID</th>
            <th>VALUE</th>
        </tr>
    </thead>
    <tbody>
		<%
			try {
				InitialContext ctx = new InitialContext();
				DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/oa");	

				Connection conn = ds.getConnection();
				Statement stmt = conn.createStatement();
				ResultSet rst = stmt.executeQuery(" select id,value from db_test");

				while (rst.next()) {
					out.println("<tr>");
					out.println("<td>"+rst.getString("ID")+"</td>");
					out.println("<td>"+rst.getString("VALUE")+"</td>");
					out.println("</tr>");
				}
				conn.close();
				conn = null;
			} catch (Exception e){
				e.printStackTrace();
			}
		%>
    </tbody>
    </table>
</body>
</html>